package com.thti.mecool.client.adapter;

import android.app.Activity;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.content.DialogInterface;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.TextView;

import com.thti.mecool.client.activity.R;
import com.thti.mecool.client.widget.AlterDialogWidget;

public class SalersRateAdapter extends BaseAdapter {
	Context context;
	
	public SalersRateAdapter(Context context) {
		super();
		this.context = context;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return 6;
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		View view =((Activity) context).getLayoutInflater().inflate(R.layout.mecool_salers_rate_item,null);
		TextView title=(TextView)view.findViewById(R.id.mecool_salers_rate_item_title);
		title.setText("北平超市工作计划");
		Button contentBtn,rateBtn;
		contentBtn=(Button)view.findViewById(R.id.mecool_salers_rate_item_content);
		rateBtn=(Button)view.findViewById(R.id.mecool_salers_rate_item_rate);
		contentBtn.setOnClickListener(clickListener);
		rateBtn.setOnClickListener(clickListener);
		return view;
	}
	
	OnClickListener clickListener=new OnClickListener() {
		
		@Override
		public void onClick(View v) {
			// TODO Auto-generated method stub
			switch(v.getId()){
			case R.id.mecool_salers_rate_item_rate:
				AlterDialogWidget rateDialog=new AlterDialogWidget(context);
				rateDialog.setTitle("选择评分");
				rateDialog.setItems(new String[]{"1","2","3","4","5"});
	//			ProjectDialog.setReturnView(showShop);
				rateDialog.show();
			break;
			case R.id.mecool_salers_rate_item_content:
				Builder builder = new Builder(context);
				builder.setInverseBackgroundForced(true);
				TextView title=new TextView(context);
				title.setText("内容");
				builder.setCustomTitle(title);
				builder.setMessage("xxxxxxxxxxxxxxxxxxxxxxxxxx");
				builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
					
					@Override
					public void onClick(DialogInterface dialog, int which) {
						// TODO Auto-generated method stub
						
					}
				});
				builder.create();
				builder.show();	
			}
	   }
	};

}
